<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>修改联系人信息</title>
	<link rel="stylesheet" type="text/css" href="../../css/tc/tc.css" />
	<style type="text/css">
		body{
			overflow-y: hidden;
		}
	</style>
</head>
<body>
<script src="../../js/jquery3.js" type="text/javascript" charset="utf-8"></script>
<script src="../../layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/edit.js"></script>
<!--弹框-->
<div class="cd-popup">
	<div class="cd-popup-container">
		<p></p>
		<div class="cd-buttons">
			<form class="form">
				<div class="bd1">
					<div><span>客户名称：</span><br><input type="text" name="c_name" id="c_name" placeholder="姓名" /></div>
					<div><span>客户性别：</span><br>
						<select id="c_sex" name="c_sex" class="from">
							<option value=""><span style="color: #C9C9C9; ">客户性别</span></option>
							<option value="girl">女</option>
							<option value="boy">男</option>
						</select></div>
					<div><span>客户手机：</span><br><input type="text" name="c_tel" id="c_tel" placeholder="号码" /></div>
					<div><span>客户邮箱：</span><br><input type="text" name="c_email" id="c_email" placeholder="邮箱" /></div>
					<div class="layui-input-inline"><span>下次联系时间：</span><br> <input type="text" class="layui-input" name="next_time" id="next_time"
																					placeholder="yyyy-MM-dd"></div>
					<div><span>客户地址：</span><br>
						<input type="text" class="layui-input" name="c_address" id="c_address"
							   placeholder="详细地址">
					</div>
				</div>
				<div class="bd2">
					<div><span>客户来源：</span><br>
						<select id="c_from" name="c_from" class="from">
							<option value=""><span style="color: #C9C9C9;">客户来源</span></option>
							<option value="邮件营销">邮件营销</option>
							<option value="广告">广告</option>
							<option value="直接访问">直接访问</option>
							<option value="搜索引擎">搜索引擎</option>
						</select></div>
					<div><span>客户行业：</span><br><input type="text" name="c_industry" id="c_industry" placeholder="行业" /></div>
					<div><span>客户负责人：</span><br><input type="text" name="c_principal" id="c_principal" placeholder="负责人" /></div>
<!--					<div><span>成交状态：</span><br>-->
<!--						<select id="c_status" name="c_status" class="from">-->
<!--							<option value=""><span style="color: #C9C9C9;">成交状态</span></option>-->
<!--							<option value="已成交">已成交</option>-->
<!--							<option value="未成交">未成交</option>-->
<!--						</select></div>-->
					<div class="layui-input-inline"><span>客户级别：</span><br>
						<select id="c_level" name="c_level" class="from">
							<option value=""><span style="color: #C9C9C9;">客户级别</span></option>
							<option value="重点客户">重点客户</option>
							<option value="普通客户">普通客户</option>
							<option value="潜在顾客">潜在顾客</option>
						</select>
					</div>
				</div>
				<input type="submit" value="提交" class="submit" />
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	layui.use('laydate', function() {
		var laydate = layui.laydate;

		//常规用法
		laydate.render({
			elem: '#next_time'
		});
	})
	$(function () {
		let c_id=getParameter("c_id");
		$.post("/contact/findById",{"c_id":c_id},function (res) {
			$("#c_name").val(res.c_name);
			$("#c_sex").val(res.c_sex);
			$("#c_tel").val(res.c_tel);
			$("#c_email").val(res.c_email);
			$("#c_address").val(res.c_address);
			$("#c_from").val(res.c_from);
			$("#c_industry").val(res.c_industry);
			$("#c_principal").val(res.c_principal);
			// $("#c_status").val(res.c_status);
			$("#c_level").val(res.c_level);
			$("#next_time").val(res.next_time);

		})

		$(".form").submit(function () {

			$.ajaxSettings.async = false;
			$.post("/contact/update?c_id="+c_id, $(this).serialize(), function (data) {
				if (data == "success") {
					alert("修改成功")

					window.parent.location.reload(); //刷新父页面
					var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
					parent.layer.close(index);
				}
			})
		})
	})
</script>
</body>
</html>
